package effectiveJava.throwble;

import java.io.Serializable;

public class Result implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -8085706454769863447L;

    private int            resultCode;                              // 0-成功
    private String            resultCodeDescription;                   // 结果描述
    private Object            data;                                    // 业务数据

    public Result(){

    }

    private static String paramDesc          = "参数错误";
    private static String errorDesc          = "系统错误请稍后重试";
    private static String illegalDesc        = "合法性校验失败";
    private static String successDesc        = "成功";
    public static Result  successResult      = new Result( 0, successDesc, "");
    public static Result  illegalErrorResult = new Result( 3, illegalDesc, "");
    public static Result  errorResult        = new Result( 2, errorDesc, "");
    public static Result  paramError         = new Result( 1, paramDesc, "");

    public Result( int resultCode, String resultCodeDescription, Object data){
        this.resultCode = resultCode;
        this.resultCodeDescription = resultCodeDescription;
        this.data = data;
    }

    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultCodeDescription() {
        return resultCodeDescription;
    }

    public void setResultCodeDescription(String resultCodeDescription) {
        this.resultCodeDescription = resultCodeDescription;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "resultCode=" + resultCode +
                ", resultCodeDescription='" + resultCodeDescription + '\'' +
                ", data=" + data +
                '}';
    }
}
